﻿using Models;
using Student.登录;
using System;
using System.Windows.Forms;


namespace Student.主界面
{
    public partial class 学生端主界面 : Form
    {
        public 学生端主界面()
        {
            InitializeComponent();
        }

        
        private void button1_Click(object sender, EventArgs e)
        {
            Group_setting  f1 = new Group_setting();
            f1.ShowDialog();
        }

        // select_T_Click 完成
        private void button2_Click(object sender, EventArgs e)
        {
            if (Models.LogInfo.student.is_gleader == 0)
            {
                MessageBox.Show("队长才能选择导师！");
                return;
            }
            业务界面.选择导师 f = new 业务界面.选择导师();
            f.ShowDialog();
        }

        // logout_click完成
        private void button3_Click(object sender, EventArgs e)//11-16-7:22 退出功能有问题
        {
            clear_controls();
            control_forms();

        }

        private void control_forms()
        {
            this.Visible = false;           

            学生端登录 frm_login = new 学生端登录();
            if (frm_login.ShowDialog() == DialogResult.OK)
            {
                this.Visible = true;
                textBox1.Text = LogInfo.student.stu_name;
                textBox3.Text = LogInfo.student.phone;
                textBox2.Text = LogInfo.student.stu_no;
                if (LogInfo.stu_Group != null)
                {
                textBox4.Text = LogInfo.stu_Group.project_name;
                textBox5.Text = LogInfo.stu_Group.teacher_name;
                }
            }
            else
                this.Close();
        }

        private void clear_controls()
        {
            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";
            textBox4.Text = "";
            textBox5.Text = "";
            this.Visible = false;
            LogInfo.student = null;
            LogInfo.stu_Group = null;
        }

        private void 学生端主界面_Load(object sender, EventArgs e)
        {
        }

        // NOTE:搬运完成, 当不起作用
        private void 学生端主界面_Shown(object sender, EventArgs e)
        {
            control_forms();
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox3_TextChanged(object sender, EventArgs e)
        {

        }

        private void 学生端主界面_FormClosed(object sender, FormClosedEventArgs e)
        {
            System.Environment.Exit(0);
        }
    }
}
